package com.cskaoyan.bean;

/**
 * 线程安全的懒加载 → 静态内部类实现的
 */
public class MySingleton5 {
    private MySingleton5() {
    }
    private static MySingleton5 mySingleton5;

    public static MySingleton5 getInstance() {
        return Inner.get();//调用到这里，静态内部类才开始加载
    }

    static class Inner {
        //实例化过程放在静态内部类的静态代码块儿中
        static {
            mySingleton5 = new MySingleton5();
        }
        public static MySingleton5 get() {
            return mySingleton5;
        }
    }
}
